package redora.test.rdo.businessrules;

import org.jetbrains.annotations.NotNull;
import redora.service.BusinessRuleViolation;
import redora.test.rdo.businessrules.base.JUnitSortedChildBusinessRulesBase;

/**
* Custom business rule implementations go here. For a business rule you must first
* define them in the object model (see <a href="http://code.google.com/p/redora/wiki/BusinessRules">the manual</a>).
* The generator will then generate a ruleId handle on JUnitSortedChildBusinessRulesBase like:
* <code>
* JUnitSortedChildBusinessRules.BR_[number]
* </code>
* which can be used to add a new BusinessRuleViolation. For example like this:
* <code>
  new BusinessRuleViolation(JUnitSortedChild
        , JUnitSortedChildFields.myNaughtyField
        , JUnitSortedChildBusinessRules.BR_1
        , BusinessRuleViolation.Action.Update));
* </code>
* As you can image the BusinessRuleViolation object make it possible to pinpoint the
* violate rule to the end user. In the object model you can set messages (with parameters)
* in any of the languages you want to support. The ruleId handle, JUnitSortedChildBusinessRules.BR_1
* in this example will point to the message you have define in the model, that could be something like:
<code>
    &lt;businessRules&gt;
        &lt;businessRule number="1" javadoc="Only updates at night are allowed." attributes="myNaughtyField"&gt;
            &lt;message language="en"&gt;You are too early, come back at {0}&lt;/message&gt;
        &lt;/businessRule&gt;
    &lt;/businessRules&gt;
</code>
* You can use JUnitSortedChildBusinessRules by invoking the static check() method.
* @see BusinessRuleViolation
* @author Redora (www.redora.net)
*/
public class JUnitSortedChildBusinessRules extends JUnitSortedChildBusinessRulesBase {

    /*
    * Example
    @NotNull
    public static Set<BusinessRuleViolation> onUpdate(@NotNull JUnitSortedChild pojo)
            throws BusinessRuleViolationException {
        Set<BusinessRuleViolation> retVal = JUnitSortedChildBusinessRulesBase.onUpdate(pojo);
        //for example check if the updateDate is newer then the last updateDate
        if (pojo.dirty.containsKey(JUnitSortedChildFields.updateDate) {
          if (pojo.dirty.get(JUnitSortedChildFields.updateDate) != null
                        && pojo.dirty.get(JUnitSortedChildFields.updateDate).compareTo(pojo.getUpdateDate() > 0) {
              retVal.add(new BusinessRuleViolation(
              JUnitSortedChild, JUnitSortedChildFields.updateDate, BR_1, Action.Update));
          }
        }
        return retVal;
    }
    */
}
